package com.chuqiyun.authorization.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chuqiyun.authorization.dao.CommodityDao;
import com.chuqiyun.authorization.entity.Commodity;
import com.chuqiyun.authorization.service.CommodityService;
import org.springframework.stereotype.Service;

/**
 * 商品(Commodity)表服务实现类
 *
 * @author mryunqi
 * @since 2023-04-19 17:06:56
 */
@Service("commodityService")
public class CommodityServiceImpl extends ServiceImpl<CommodityDao, Commodity> implements CommodityService {

    /**
     * @Author: mryunqi
     * @Description: 获取单个产品信息
     * @DateTime: 2023/4/19 23:00
     * @Params: String name 产品名
     * @Return Product
     */
    @Override
    public Commodity getCommodity(String name) {
        QueryWrapper<Commodity> commodityQueryWrapper = new QueryWrapper<>();
        commodityQueryWrapper.eq("name", name);
        return this.getOne(commodityQueryWrapper);
    }

    /**
    * @Author: mryunqi
    * @Description: 获取指定分页的数据
    * @DateTime: 2023/4/21 12:24
    * @Params: Integer page 页数
    * @Params: Integer size 每页数据
    * @Return Page<Commodity>
    */
    @Override
    public Page<Commodity> getCommodityList(Integer page, Integer size) {
        Page<Commodity> commodityPage = new Page<>(page, size);
        return this.page(commodityPage);
    }
    @Override
    public Page<Commodity> getCommodityList(Integer page, Integer size, QueryWrapper<Commodity> queryWrapper) {
        Page<Commodity> commodityPage = new Page<>(page, size);
        return this.page(commodityPage,queryWrapper);
    }
}

